home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / PROGRAM / AECUR100.ARJ / EXPLDWIN.C < prev    next >
C/C++ Source or Header  |  1990-03-08  |  1KB  |  65 lines

  1. /*----------------------------------------------------------------------
  2.  *
  3.  *  expldwin.c
  4.  *
  5.  *  copyright (c) 1987,88,89,90 J. Alan Eldridge
  6.  *
  7.  *  "explodes" a boxed window onto the screen
  8.  *
  9.  *----------------------------------------------------------------------
  10.  */
  11.  
  12. #include "curses.h"
  13.  
  14. int
  15. expldwin(wptrs, l, c, y, x, v, h)
  16. WINDOW  *wptrs[2];
  17. int     l, c, y, x, v, h;
  18. {
  19.     int lc, cc, yc, xc, n;
  20.  
  21.     WINDOW *winp, *subp;
  22.  
  23.     lc = l % 2 ? 1 : 2;
  24.     cc = c % 2 ? 1 : 2;
  25.     yc = y + l / 2 - lc / 2;
  26.     xc = x + c / 2 - cc / 2;
  27.  
  28.     for (;;) {
  29.         int i;
  30.  
  31.         winp = newwin(lc+2,cc+2,yc-1,xc-1);
  32.  
  33.         if (!winp)
  34.             return ERR;
  35.         
  36.         box(winp,v,h);
  37.         wrefresh(winp);
  38.  
  39.         if (lc == l && cc == c)
  40.             break;
  41.         else
  42.             delwin(winp);
  43.  
  44.         n = (i = l - lc) > 4 ? 6 : i;
  45.         lc += n;
  46.         yc -= n / 2;
  47.  
  48.         n = (i = c - cc) > 6 ? 8 : i;
  49.         cc += n;
  50.         xc -= n / 2;
  51.     }
  52.  
  53.     subp = subwin(winp, lc, cc, yc, xc);
  54.         
  55.     if (subp) {
  56.         wptrs[0] = winp;
  57.         wptrs[1] = subp;
  58.         return OK;
  59.     } else {
  60.         delwin(winp);
  61.         wptrs[0] = wptrs[1] = NULL;
  62.         return ERR;
  63.     }
  64. }
  65.